//
//  NewFeatureViewController.m
//  weibo110
//
//  Created by 臧松 on 15/12/28.
//  Copyright © 2015年 臧松. All rights reserved.
//

#import "NewFeatureViewController.h"
#import "NewFeatureViewLayout.h"
#import "NewFeatureViewCell.h"
@interface NewFeatureViewController ()

@end

@implementation NewFeatureViewController

-(instancetype)init{
    
    
    if (self = [super initWithCollectionViewLayout:[[NewFeatureViewLayout alloc]init]]) {
        
        self.collectionView.pagingEnabled = YES;
        self.collectionView.bounces = NO;
        self.collectionView.showsHorizontalScrollIndicator = NO;
    }
    return self;
}
static NSString * const newFeatureCellId = @"newFeatureCellId";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Register cell classes
    [self.collectionView registerClass:[NewFeatureViewCell class] forCellWithReuseIdentifier:newFeatureCellId];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark <UICollectionViewDataSource>



- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
   NewFeatureViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:newFeatureCellId forIndexPath:indexPath];
    cell.imageIndex = indexPath;
    // Configure the cell
    return cell;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

    int page = scrollView.contentOffset.x/ scrollView.bounds.size.width;
    if (page != 3) {
        return;
    }
    NewFeatureViewCell* cell = (NewFeatureViewCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:page inSection:0]];
    
    [cell showButtonAnim];
    
}
// 隐藏状态栏
-(BOOL)prefersStatusBarHidden{
    return YES;
}
@end
